/**
 * =============================================================================
 * SourceMod Bots for Day of Defeat Source BETA
 * (C)2010 Dog - www.theville.org
 *
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
 * =============================================================================
 *
 */

------------------------
DISCLAIMER
------------------------
Please note that this is a beta version of DODS-BOTS which is
still undergoing final testing before its official release. The
plugin, its source code and all content are provided on an
as is and as available basis. Dog, TheVille.Org or AlliedModders 
do not give any warranties,
whether express or implied, as to the suitability or usability of the
plugin, its source code or any of its content.

Dog, TheVille.Org, or AlliedModders will not be liable for any loss, 
whether such loss is direct,indirect, special or consequential, suffered 
by any party as a result of their use of the DoDS-BOTS plugin, its 
source code or content. 
Any use of the plugin is done at the users own risk 
and the user will be solely responsible for any damage to any computer 
system or loss of data that results from such activities.

Should you encounter any bugs, glitches, lack of functionality or
other problems, please let us know immediately so we
can rectify these accordingly. Your help in this regard is greatly
appreciated.

--Dog
Vancouver BC, Canada

------------------------
CONTACTING ME
------------------------
Where I usually hang out - one of the best gaming communities out there!
http://www.theville.org

This plugin was beta tested at http://dodsourceplugins.net
A great community with some of the most talented DODS programmers
Thanks to Andi67, Andersso, Feuersturm, Darkranger, Piotr3k1447, Leitwolf and all the other alpha/beta testers.

If you have general questions, add them on the forums at http://dodsourceplugins.net


------------------------
DODS-BOTS
------------------------
December 2010

This is a BETA test of DoDS-Bots.
BETA means that it may have bugs and should not be run on a production server.

Users can use this thread: http://www.dodsourceplugins.net/viewtopic.php?f=18&t=134

Rather than saying 'The bot mod is broken', try to figure out where the bug is happening, what is causing it, does it only happen after certain events, how often does it happen, and maybe offer suggestions for a fix.

------------------------
NOTES
------------------------
1. The plugin is initially set up with 16 bots - 8 per side. This will give the server a good run through and you may find CPU cycles climbing. If you can, let me know by how much.
If you want to run with fewer bots, change the cvar bots_number in your server.cfg file.

2. If you inadvertently run a map without map data, the plugin will shut off and no bots will appear. 
You will need to set 'bots_setup 0' and 'bots_enabled 1' and reload one of the set maps.  See waypointing below, if you need waypoints for certain maps.

3. The bots are accurate.  Adjust their accuracy in the /data/botsprofile.db file.

4. This plugin will generate log files in /addons/sourcemod/logs/

5. This plugin has been tested on a updated DoDS server with the base SourceMod 1.3.7 install, with the following popular plugins:
	SourceBans plugin, 
	HLStatsX:CE plugin, 
	Admin Sentinel plugin, 
	CommsTools plugin, 
	AdsMySQL plugin, 
	Permanent Rename plugin, 
	Rcon Lock plugin, 
	Radio plugin
	
	Plugins that currently do not run with DoDS-Bots:
	DoD Block Exploits

6.  This plugin is NOT intended as a method for server filling.  If you need bots to fill your server, you have serious issues.  The only thing that will fill a server is other humans.  Remember that a community is what fills a server so try and get a community going first.

7.  I recommend that you do not try and make the bots seem human by giving them tags etc.  Players will figure out you are trying to fool them and not come back.

8.  Each bot is CPU intensive so the more bots you have, the more lag you may experience.  The SourceMod script is fast, but not as fast as C++.  If you find you server getting laggy, reduce the number of bots.  

9.  You cannot install the bots on a listen server since VALVe's last update.  Install a SRCDS setup instead.  Running bots on your machine, while playing on it at the same time, is not recommended.

------------------------
GETTING THE SERVER READY
------------------------
1. The server should have the latest version of SourceMod: http://www.sourcemod.net/snapshots.php
At time of writing the current version: 1.3.7

2. Install DoDHooks by Andersso: http://www.dodsourceplugins.net/viewtopic.php?f=33&t=68
dodhooks.txt goes in /srcds/orangebox/dod/addons/sourcemod/gamedata
dodhooks.ext.dll (Windows) or dodhooks.ext.so (Linux) goes in /srcds/orangebox/dod/addons/sourcemod/extensions

3. Install SDKHooks by DJ Tsunami: http://forums.alliedmods.net/showthread.php?t=106748
sdkhooks.games.txt goes in /srcds/orangebox/dod/addons/sourcemod/gamedata
sdkhooks.ext.dll (Windows) or sdkhooks.ext.so (Linux) goes in /srcds/orangebox/dod/addons/sourcemod/extensions

4. Install the Bot Navigation files and Bot Profile data
Note the maps that you have nav files for...you will not be able to run any other maps until you waypoint them, so change your mapcycle accordingly.
Place the contents of the Data directory in /srcds/orangebox/dod/addons/sourcemod/data
You may wish to edit the botsprofile.db file, if you want to customize the names of your bots or their skill level. Use an editor like Notepad++ to edit the .db file.

5. Install the Plugin.
Place dods-bots.smx in /srcds/orangebox/dod/addons/sourcemod/plugins

6. Optional - Add CVARs to server.cfg - not necessary as the plugin will run on default settings.

7. Restart the server


------------------------
CVARS
------------------------
Place in 

bots_enabled <0|1>
--Default is 1
--Used to turn on and off the plugin

bots_setup <0|1>
--Default is 0
--Used to switch the plugin into setup mode for waypointing

bots_number <#>
--Default is 8
--Number of bots that spawn at the beginning of the map

bots_info <0|1>
--Default is 0
--Will report what bots are doing such as the entity of the flag they are trying to cap

bots_maxsets <#>
--Default is 8
--Sets the number of waypoint sets required, PER TEAM.  So if you specify 8, then you must have 8 waypoint sets for each team.

bots_leave <#>
--Default is 8
--Number of humans needed to force bots to leave


------------------------
COMMANDS
------------------------
sm_waypoint <add|show> <#>
--where '#' is the waypoint set you are saving (see below on waypointing)
-- 'add' will add a waypoint to that set
-- 'show' will show all the waypoints for that set

sm_where
--returns the coords and height above the player - used for waypointing


------------------------
PLAY
------------------------
The bots are stupid but will try and work their own way out of situations.

They are limited in that:
-- they cannot plant bombs
-- they do not prone or crouch
-- if you recompile the source code so that the bots use MGs or rockets, be prepared for server instability.

Other than that, they are as accurate as hell.
Bots can be customized via the botsprofile.db file located in the /data folder of SourceMod.


------------------------
CREATING WAYPOINTS
------------------------
Waypoint creation is not easy. It is both frustrating and time consuming.
It will take a certain amount of patience and a good text editor like Notepad++!

First of all, set

bots_setup 1

to turn on setup mode.

You need to create a minimum of 8 (depends on the cvar bots_maxsets) sets of waypoints for each team. The plugin will not function if there are less sets than specified in bots_maxsets.
Each set is a series of points around the map for the bots to follow.  Bots will regularly swap between sets so care is needed.
The more sets you have, the less the bots will clump together.  Since most maps have no more than 20 spawn points, it is unlikely you will need more than 20 sets per team.
Having said that, having 8 sets is efficient and consumes less server memory and hence is the default.

Bind a key to "sm_waypoint add 1" to waypoint the first set. 

When you spawn, all the spawn points will be highlighted so stand near a group and add point #1. Then carefully run around adding waypoints, being careful to make sure that the waypoint can be seen by the previous waypoint. Be aware that bots need help to get around sandbags and walls so plan a route around obstacles.  Try to add a waypoint in front of a door and behind a door.

Also be aware that the bots will reverse in direction once they reach the end of their set of waypoints.  Therefore, be careful when planning routes out of windows and drops to the ground as the bots will be unable to go back that way.

Then repeat for "sm_waypoint add 2" and so on. 

On average, waypointing, carefully done will take about 2 hours. If you do it quicker than that, you might have missed something.

To see your waypoints, type 'sm_waypoint show 1' to display the waypoints for set 1.

------------------------
ADDING FLAGS
------------------------
The flags are probably the most awkward bit. When you touch a flag entity, it will report back what the entity is, when in setup mode.

You then have to look at which is the first Allied flag, then make a note. And then the second Allied flag, and make a note. 
Do this for all the flags and then look at the other bot .nav files and see how the data is entered and replicate that in the newly create bot_mapname.nav file.
The plugin will still function without flag data, but the bots will not stop and capture, if there is no flag data.

Run the bots around the waypoints and make a note of the flag entity when they touch them and which team owns it.  This will help you figure out which flag is which.
Maps like Kalt will be pretty easy to do while others like Anzio, where the flags are all over the place and not in any obvious order, will be much more difficult.

Having created your NAV file, and it is successful, please submit your NAV file for others to use.


------------------------
BOT PROFILES
------------------------
Bot profiles allow server owners the opportunity to rename their bots and adjust their skill.
Make sure that you do not accidentally erase any quotation marks.
Skill level: 0 - Poor aim, unlikely to hit much ...... 5 - Very accurate


------------------------
SOURCE CODE
------------------------
https://www.assembla.com/code/dods-bots/subversion/nodes/trunk


------------------------
CONTACTING ME
------------------------
I have a normal job outside programming, so may not always be available.

Contact me at http://www.theville.org
My email: strontiumdog at boff dot ca

If you find a certain map difficult to waypoint then let me know and I might do it for you.

-- Dog